<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="plugins/element-ui/index.css"/>
    <link rel="stylesheet" href="styles/icon/iconfont.css"/>
</head>
<body>
<div id="app">
    <el-form status-icon  ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-form-item  label="邮箱" prop="pass">
            <el-input v-model="email"></el-input>
        </el-form-item>
        <el-form-item  label="密码" prop="checkPass">
            <el-input v-model="password" type="password"  autocomplete="off"></el-input>
        </el-form-item>

        <el-form-item>
            <el-button type="primary" @click="login">登录</el-button>
            <el-button @click="reset">重置</el-button>
        </el-form-item>
    </el-form>
</div>
</body>
<!-- 开发环境版本，包含了有帮助的命令行警告 -->
<script src="plugins/vue/vue.js"></script>
<!-- 引入组件库 -->
<script src="plugins/element-ui/index.js"></script>
<!-- 引入axios -->
<script src="plugins/axios/axios.min.js"></script>
<script src="js/request.js"></script>
<script src="api/admin.js"></script>
<script>
    new Vue({
        //前端中的#号代表获取id
        el:'#app',
        data(){
            return {
                //这里填写数据
                email:'',
                password:''
            }
        },
        methods:{
            login(){
                loginApi({
                    "email":this.email,
                    "password":this.password
                }).then(res=>{
                    console.log(res)
                    if (res.data.flag){
                        //前端存token
                        localStorage.setItem("token",res.data.data)
                    }
                })
            },
            reset(){
                //前端取token并放到一个token变量中
                let token = localStorage.getItem("token")
                console.log("token"+token)
            }
        }
    })
</script>
</html>